<template>
  <li :class="{'leaf_li':true,'save':saveFlag}" >
    <label>{{leafItem.uumsFunction.functionName}}</label>
    <span @click.stop="addMenu" class="icon-btn add" ></span>
  </li>
</template>

<script>
    export default {
      name: "leaf-html",
      props:['leafItem'],
      data(){
        return {
          clickFlag:''
        }
      },
      computed:{
        saveFlag(){
          let t;
          if(this.clickFlag === ''){
            t = this.leafItem.customMenu && this.leafItem.customMenu.id
          }else{
            t = this.clickFlag;
          }
          return t;
        }
      }
      ,methods:{
        addMenu(){
          this.axios.post(
            MENUUSER_SERVICE_URL + 'customMenu/addCustomMenu',
            {menuCode: this.leafItem.uumsFunction.functionCode}).then((res)=>{
            let data = res.data;
            if (data.status === 'SUCCESS') {
              this.clickFlag = true;
              // this.axios.post(
              //   LOGSTATISTICS_SERVICE_URL + "systemGeneralize/customMenuUseLog",{
              //   "menuCode": this.leafItem.uumsFunction.functionCode,
              //   "menuName": this.leafItem.uumsFunction.functionName,
              //   "active": active
              // });
            } else if (data.status === 'FAILURE') {
              Ext.Msg.alert("操作失败 !", data.body);
            }
          })
        }
      }
    }
</script>

<style  scoped>

</style>
